import { ResPage, Forum, ResultData } from "@/api/interface/index";
import http from "@/api";

/**
 * @name 帖子管理模块
 */
// 获取帖子列表
export const getPostList = (params: Forum.ReqPostParams) => {
  return http.post<ResPage<Forum.ResPostList>>(`/bbs/post/query`, params);
};
// 获取帖子详情
export const getPostDtl = (params: { postId: string }) => {
  return http.post<ResultData>(`/bbs/post/detail`, params);
};
// 新增帖子
export const sendPost = (params: { postTitle: string; postContent: string }) => {
  return http.post(`/bbs/post/add`, params);
};
// 删除帖子
export const deletePost = (params: { postId: string }) => {
  return http.post(`/bbs/post/remove`, params);
};

// 获取评论列表
export const getCommentList = (params: Forum.ReqCommentParams) => {
  return http.post<ResPage<Forum.ResCommentList>>(`/bbs/comment/query`, params);
};

// 新增评论
export const sendComment = (params: { postId: string; commentContent: string }) => {
  return http.post(`/bbs/comment/add`, params);
};

// 删除评论
export const deleteComment = (params: { commentId: string }) => {
  return http.post(`/bbs/comment/remove`, params);
};

// 获取回复列表
export const getReplyList = (params: { commentId: string }) => {
  return http.post<ResPage<Forum.ResReplyList>>(`/bbs/reply/query`, params);
};

// 新增回复
export const sendReply = (params: { commentId: string; replyContent: string }) => {
  return http.post(`/bbs/reply/add`, params);
};

// 删除回复
export const deleteReply = (params: { replyId: string }) => {
  return http.post(`/bbs/reply/remove`, params);
};
